package com.cg.slms.dao;

import java.util.ArrayList;
import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;

import com.cg.slms.domain.Client;

public class ClientDao implements IClientDao{
	private SqlSessionTemplate sqlSession;
	public List<Client> findClient(Client client){
		List<Client> clients=new ArrayList<Client>();
		clients=sqlSession.selectList("findClient", client);
		return clients;
	}
	public SqlSessionTemplate getSqlSession() {
		return sqlSession;
	}
	public void setSqlSession(SqlSessionTemplate sqlSession) {
		this.sqlSession = sqlSession;
	}
	//增加
			public boolean addClient(Client client) {
				int ret=sqlSession.insert("addClient", client);
				if (ret>0) {
					return true;
				} else {
					return false;
				}
			}
			//修改
			public boolean updateClient(Client client) {
				int ret=sqlSession.update("updateClient", client);
				if (ret>0) {
					return true;
				} else {
					return false;
				}
			}
			//查id
			public Client findClientById(String id) {
				Client client=sqlSession.selectOne("findClientById", id);
				return client;
			}
			//删除
			public boolean deleteClientById(String id) {
				int ret=sqlSession.delete("deleteClientById", id);
				if (ret>0) {
					return true;
				} else {
					return false;
				}
			}

}
